{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "Notes on numpy (for beginners, like me!)\n",
    "\n",
    "[YouTube Tutorial](https://www.youtube.com/watch?v=gtejJ3RCddE)\n",
    "\n",
    "[Documentation](http://docs.scipy.org/doc)\n",
    "\n",
    "point to point multiplication by default\n",
    "@ (python3) matrix mult\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import scipy as sp\n",
    "import sys\n",
    "import os\n",
    "\n",
    "# Impression des nombres flottants plus lisibles\n",
    "np.set_printoptions(suppress=True)\n",
    "\n",
    "# Ajouter le path de notre librairie\n",
    "sys.path.append(os.getcwd() + '/../')\n",
    "#print('Current path: ',sys.path)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "De la documentation Markdown ici: \n",
    "\n",
    "* Il est possible d'intégrer de la documentation avec du code qu'on peut \"rouler\" en direct pour voir le résultat.\n",
    "* Nous pouvons directement aller chercher les algorithmes dans notre librairies.\n",
    "* Si nous stockons les données dans un format intermédiaire, il est possible de reproduire tout le traitement ici.\n",
    "* Il y a aussi moyen d'intégrer des graphiques (à tester)\n",
    "* Donc, la documentation et le code suit les données (dans une certaine mesure).\n",
    "* "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loading:  ../resources/test_data.mat\n",
      "data length:  100000\n",
      "start time  0.0  stop_time  999.9902509152889\n",
      "input dims (100000, 4)\n",
      "time length 100000 [  0.           0.01         0.02000001 ... 999.97025091 999.98025091\n",
      " 999.99025092]\n",
      "size  100000 100000 100000\n",
      "mag :  [[  0.           0.9365881 ]\n",
      " [  0.01         0.89526166]\n",
      " [  0.02000001   0.93828809]\n",
      " ...\n",
      " [999.97025091   0.88984261]\n",
      " [999.98025091   0.89458978]\n",
      " [999.99025092   0.87610671]]\n",
      "mag shape  (100000, 2)\n",
      "padding size:  2000\n",
      "should have nb_epochs 17.0\n",
      "Total size 102000\n",
      "epochs: 17.0 counts: [6242.57407562 6810.92168252 6729.89985834 6421.46989326 6647.93630274\n",
      " 6323.33779219 6589.86096251 6786.68922522 6685.4995978  6451.86707099\n",
      " 6808.11254355 6599.08122927 6144.87720106 6175.58911919 6672.52381565\n",
      " 6705.41724259 4242.111169  ]\n"
     ]
    }
   ],
   "source": [
    "import DataImporter as importer\n",
    "import Algorithms as algo\n",
    "\n",
    "# Load test data\n",
    "rawData = importer.load_mat_file('../resources/test_data.mat')['data2']\n",
    "\n",
    "# Convert time to seconds\n",
    "# Our example have fractional days increments\n",
    "rawData[:, 0] = rawData[:, 0] * 24 * 60 * 60\n",
    "\n",
    "#Execute algorithm\n",
    "[nb_epochs, my_counts] = algo.freedson_adult_1998(rawData, epoch_secs=60 ,rate=100)\n",
    "\n",
    "# Les résultats sont imprimés dans la prochaine cellule, on peut donc montrer \n",
    "# des résultats intermédiaires\n",
    "print('epochs:',nb_epochs, 'counts:',my_counts)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Rapport\n",
    "* Je songe à intégrer une partie rapport dans ce format. Visible dans jupyter notebooks (et possiblement en version cloud).\n",
    "* Il y a moyen d'intégrer du code HTML!\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/Nm2ggyAW4rw\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen></iframe>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%html\n",
    "\n",
    "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/Nm2ggyAW4rw\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen></iframe>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# On peut mettre des formules!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "\\begin{align}\n",
       "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\   \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
       "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
       "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0\n",
       "\\end{align}"
      ],
      "text/plain": [
       "<IPython.core.display.Latex object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%latex\n",
    "\\begin{align}\n",
    "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\   \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
    "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
    "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0\n",
    "\\end{align}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
